package com.liming.shop.controller;

import com.liming.common.pojo.dto.shop.ShopAddOrUpdateDTO;
import com.liming.common.pojo.dto.shop.ShopPageQuery;
import com.liming.common.pojo.vo.PageVO;
import com.liming.common.pojo.vo.shop.ShopVO;
import com.liming.common.result.LMResult;
import com.liming.shop.service.ShopMircoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author liming
 * @date 2025/3/9
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "商店接口-Service")
@RequestMapping("/service/shop")
public class ShopMircoController {

    private final ShopMircoService shopMircoService;

    @GetMapping
    public LMResult<PageVO<ShopVO>> page(ShopPageQuery query) {
        return LMResult.success(shopMircoService.pageShop(query));
    }

    @GetMapping("{pickupPointId}")
    public LMResult<String> pickupPointInfoById(@PathVariable Long pickupPointId) {
        return LMResult.success(shopMircoService.pickupPointInfoById(pickupPointId));
    }

    @PostMapping
    public LMResult<Boolean> add(@RequestBody ShopAddOrUpdateDTO dto) {
        return LMResult.success(shopMircoService.saveShop(dto));
    }

    @PutMapping
    public LMResult<Boolean> update(@RequestBody ShopAddOrUpdateDTO shopAddOrUpdateDTO) {
        return LMResult.success(shopMircoService.updateShop(shopAddOrUpdateDTO));
    }

    @DeleteMapping("{id}")
    public LMResult<Boolean> delete(@PathVariable Long id) {
        return LMResult.success(shopMircoService.removeById(id));
    }
}
